<?php

class Assets extends Admin_Controller
{
    function __construct()
    {

        parent::__construct();
        error_reporting(E_ALL ^ E_NOTICE);
        $this->load->helper('url_helper');
        $this->load->helper('url');
        $this->load->model('assets_model','assets');
        $this->load->model('users_model');

    }
    //获取佣金
    function commission(){
        $time_type = $_GET['time_type'];
        $status =$_GET['status'];
        if($_GET['id']){
            $data1 = $this->assets->commission($_GET['id'],$time_type,$status);
            $data['status'] = "success";
            $data['msg'] = "获取成功";
            $data['data'] = $data1;
        }else{
            $data['status'] = "fail";
            $data['msg'] = "参数错误";
            $data['data'] = "";
        }
        json_send($data);
    }

    //获取提成
    function push_money(){
        $time_type = $_GET['time_type'];
        $status =$_GET['status'];
        if($_GET['id']){
            $data1 = $this->assets->push_money($_GET['id'],$time_type,$status);
            $data['status'] = "success";
            $data['msg'] = "获取成功";
            $data['data'] = $data1;
        }else{
            $data['status'] = "fail";
            $data['msg'] = "参数错误";
            $data['data'] = "";
        }
        json_send($data);
    }

    //提成明细
    function  push_money_list(){
        $page = $this->input->get("page")?$this->input->get("page"):1;
        $limit = $this->input->get("limit")?$this->input->get("limit"):8;
        $search = $this->input->get("search");
        if($_GET['id']){
            $data1 = $this->assets->push_money_list($_GET['id'],$search,$page,$limit);
            $data['status'] = "success";
            $data['msg'] = "获取成功";
            $data['data'] = $data1;

        }else{
            $data['status'] = "fail";
            $data['msg'] = "参数错误";
            $data['data'] = "";
        }
        json_send($data);
    }

    //佣金明细
    function  commission_list(){
        $page = $this->input->get("page")?$this->input->get("page"):1;
        $limit = $this->input->get("limit")?$this->input->get("limit"):8;
        $search = $this->input->get("search");
        if($_GET['id']){
            $data1 = $this->assets->commission_list($_GET['id'],$search,$page,$limit);
            $data['status'] = "success";
            $data['msg'] = "获取成功";
            $data['data'] = $data1;

        }else{
            $data['status'] = "fail";
            $data['msg'] = "参数错误";
            $data['data'] = "";
        }
        json_send($data);
    }
    //首页金额
    function home_money(){
        $id = $_GET['id'];
        if ($id){
            $data1 = $this->assets->home_money($id);
//        var_dump($data1);exit;
            $data['status'] = "success";
            $data['msg']="获取成功";
            $data['data']=$data1;
        }else{
            $data['status'] = "fail";
            $data['msg'] = "参数错误";
            $data['data'] = "";
        }

        json_send($data);
    }
    //我的资产页金额
    function my_money(){
        $id = $_GET['id'];
        if ($id){
            $data1 = $this->assets->my_asset($id);
            $data['status'] = "success";
            $data['msg']="获取成功";
            $data['data']=$data1;
        }else{
            $data['status'] = "fail";
            $data['msg'] = "参数错误";
            $data['data'] = "";
        }

        json_send($data);
    }

    /**
     * 佣金详情
     * 传参订单ID
     */
    public function commission_detail(){
        $id = isset ( $_GET ['order_id'] ) ? $_GET ['order_id'] : NULL;

        $data = $this->assets->getOrderCommissionDetails ( $id );

        echo json_encode ( $data );
    }

    /**
     * 提成详情
     * 传参订单ID
     */
    public function push_detail(){
        $id = isset ( $_GET ['push_id'] ) ? $_GET ['push_id'] : NULL;

        $data = $this->assets->getOrderPushDetails ( $id );

        echo json_encode ( $data );
    }
}